package su.myspringapps.onlineschool.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;

import javax.persistence.*;
import java.util.List;

/**
 * Класс-сущность Teacher
 * <p/>
 * Описывает учителя
 * <p/>
 *
 * @author petr.mikhailin
 * created 12.05.2024 20:04
 */
@Entity
@Table(name = "teachers")
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Teacher {

    @Id
    @GeneratedValue(generator = "teacher-sequence-generator")
    @GenericGenerator(
            name = "teacher-sequence-generator",
            strategy = "org.hibernate.id.enhanced.SequenceStyleGenerator",
            parameters = {
                    @Parameter(name = "sequence_name", value = "teachers_id_seq")
            }
    )
    private Integer id;

    private String name;

    private Integer salary;

    private Integer age;

    @OneToMany(fetch = FetchType.EAGER)
    @JoinColumn(name = "teacher_id")
    private List<Course> courses;

}
